<?php

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Forms\Element\Select;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Email;
use Phalcon\Validation\Validator\Url;

class BusinessSystemsForm extends Form
{

    /**
     * Initialize the products form
     */
    public function initialize($entity = null, $options = array())
    {
        if (!isset($options['edit'])) {
            $element = new Text("id");
            $this->add($element->setLabel("Id"));
        } else {
            $this->add(new Hidden("id"));
        }

        $name = new Text("name");
        $name->setLabel("系统名称");
        $name->setFilters(array('striptags', 'string'));
        $name->addValidators(array(
            new PresenceOf(array(
                'message' => '系统名称是必填项'
            ))
        ));
        $this->add($name);

        $url = new Text("url");
        $url->setLabel("网址");
        $url->setFilters(array('striptags', 'string'));
        $url->addValidators(array(
            new PresenceOf(array(
                'message' => '网址是必填项'
            )),
            new Url(array(
                'message' => '不是网址类型'
            ))
        ));
        $this->add($url);

        $identifier = new Text("identifier");
        $identifier->setLabel("标识符");
        $identifier->setFilters(array('striptags', 'string'));
        $identifier->addValidators(array(
            new PresenceOf(array(
                'message' => '标识符是必填项'
            ))
        ));
        $this->add($identifier);
    }
}